<template>
	<view class="inspectContent">
		<view class="upper">
			<commonNavBar title="智能规划检查" >
				<template v-slot:right > 
					<image src="/static/img/start-route.png" style="width: 35rpx;height: 35rpx;margin-right: 10rpx;" v-if="roteStatus" @click="routePlan" />
					<image src="/static/img/navigation.png"style="width: 35rpx;height: 35rpx;margin-right: 10rpx;"  @click="checkRoute" />
					<image src="/static/img/screen.png" style="width: 35rpx;height: 35rpx;margin-right: 10rpx;"  @click="open" />
					<image src="/static/img/short.png" style="width: 35rpx;height: 35rpx;"  @click="showShortType" />
				</template>
			</commonNavBar>   
		<!--  	<view class="step" v-if="searchParams.orderBy != '1' && tabIndex == 0">
			 	<view class="search-item" @tap="switchSortBy('2')"> 
					<image class="search-icon" src="/static/img/filter.png"  /><text  :class="[ searchParams.orderBy == '2' ? 'search-active':'search-text']" >紧急程度</text>
				</view>
				<view class="search-item"  @tap="switchSortBy('3')"> 
					<image class="search-icon" src="/static/img/filter.png"  /><text  :class="[ searchParams.orderBy == '3' ? 'search-active':'search-text']"  >风险高低</text>
				</view>
				<view class="search-item"  @tap="switchSortBy('4')">  
					<image class="search-icon" src="/static/img/filter.png"  /><text :class="[ searchParams.orderBy == '4' ? 'search-active':'search-text']">距离</text>
				</view> 
			</view>  -->
			<view class="step">
				<view v-for="(tabs,index) in stepList" :key="index" @click="stepActive(index)">
					<view :class="{'active': tabIndex == index}">
						{{ tabs.step }}
					</view>
				</view>
			</view>
		</view> 
		<view class="centre"  >
			<z-paging ref="paging" autowire-list-name="inspectList"    :created-reload="false" :auto="false" autowire-query-name="listData" :how-refresher-when-reload="true" >
				<view class="li" v-for="(list, index) in inspectList" :key="index" ><!--  @tap="resultListActive(list.ID,list.IS_AUTHORITY,list.CHECK_LIST,list.SUP_PROCESS)"> -->
				 
					<view class="float">{{ list.PROCESS_NAME ? list.PROCESS_NAME : (list.processName ? list.processName : '') }}</view>
					<view class="h1">{{ index + 1 }}.{{ list.COMPANY_NAME ? list.COMPANY_NAME : (list.companyName ? list.companyName : '') }}</view>
					<view class="h2">风险等级:{{ list.RISK_LEVEL ? list.RISK_LEVEL : (list.riskLevel ? list.riskLevel : '') }}</view>
					<view class="h2" v-if="tabIndex == 0 && searchParams.orderBy == 4">距离:{{ formateNumber(list.JULI) }} </view>
					<view class="h2" v-if="tabIndex === 0">许可证号:{{ list.LICENSE ? list.LICENSE : (list.license ? list.license : '') }}</view>
					<view class="h2" v-if="tabIndex === 0">所属区局:{{ list.DEPT_QU_NAME ? list.DEPT_QU_NAME : (list.deptQuName ? list.deptQuName : '') }}</view>
					<view class="h2" v-if="tabIndex === 0">监管单位:{{ list.DEPT_NAME ? list.DEPT_NAME : (list.deptName ? list.deptName : '') }}</view>
					<view class="h2" v-if="tabIndex == 1">检查日期:{{ list.CHECK_TIME ? list.CHECK_TIME : (list.ratingDate ? list.ratingDate : '')  }}</view>
					<view class="h2" v-if="tabIndex == 1">监管周期:{{ list.CHECK_NUM  ? list.CHECK_NUM : (list.serialNum ? list.serialNum : '') }}</view>
					<view class="h2" v-if="tabIndex == 1">处理结果:{{ list.PROCESS_RESULTS ? list.PROCESS_RESULTS : (list.checkResult ? list.checkResult : '')  }}</view>
					<view class="order" v-if="tabIndex === 0">
						<view v-if="list.CHECK_LIST">
							<view class="dd" 	v-for="(order,oindex) in list.CHECK_LIST " :key="oindex"  :data-realy="order.CHECK_STATUS  == '1'" v-if="order.CHECK_STATUS == '3'"
								@tap.stop="addInspect(list.ID,list.IS_AUTHORITY,list.SUP_PROCESS,order.CHECK_STATUS, order.CHECK_INDEX,order.CHECK_ID)"
								:class=" getCheckClass(order.CHECK_STATUS)"   >
								<view class="dd1">
									<text>第{{ order.CHECK_INDEX}} 次</text> 
									<text>检查</text> 
								</view>
								<view class="triangle"></view>
							</view>
							 <view class="dd special"  v-if="checkToBeExamined(list.CHECK_LIST)"  @tap.stop="addInspect(list.ID,list.IS_AUTHORITY,list.SUP_PROCESS,'3',0)">
								<view class="dd1">
									<text >非计划</text>
									<text  v-text="'专项'"></text>   
								</view>
								<view class="triangle"></view>
							 </view> 
						 </view>
						 <view v-if="list.dailyScoreList">
						 	<view class="dd" v-for="(score, sindex) in list.dailyScoreList" :key="sindex"
						 		:data-realy="score.serialNum  == '1'"
						 		@tap.stop="productionAddInspect(list.id,list.isAuthority,score.status,score.id,score.serialNum)"
						 		:class=" productionGetCheckClass(score.status)" v-if="score.serialNum != ''">
						 	  <view class="dd1">
						 	  	<text >{{ score.serialNum === 99 ? '非计划' : `第${score.serialNum}次` }} </text>
						 		<text  v-if="score.status  == '-1'">未检查完</text>
						 	  	<text  v-if="score.status  == '0'">未检查</text>
						 	  	<text  v-if="score.status  == '1'">已检查</text>
						 	  	<text  v-if="score.status  == '2'">无需检查</text>
						 	  	<text  v-if="score.status  == '3'">过期未查</text>
						 	  	<text  v-if="score.status  == '4'">未到时间</text>
						 	  </view>
						 	  <view class="triangle"></view>
						 	</view>
						 	<view class="dd special"    @tap.stop="productionAddInspect(list.id,list.isAuthority)">
						 		<view class="dd1">
						 			<text >非计划</text>
						 			<text  v-text="'专项'"></text>   
						 		</view>
						 		<view class="triangle"></view>
						 	</view> 
						 </view>
					</view>  
					<!-- <view class="type" v-if="tabIndex === 1">{{ list.PROCESS_NAME }}</view> -->
					<image class="navigator-check" v-if="roteStatus" @tap="checkedActive(list.roteCheck,index)"
					  :src="list.roteCheck ? '../../static/img/right-bottom-checked.png' : '../../static/img/right-bottom-check.png'"
					 ></image>
				</view>
			</z-paging>
		</view>
		
		 <view class="fixed">当前已搜索到{{ total }}条数据</view> 
	<!-- 	<uni-popup ref="checkTypePopup" type="bottom"  :mask-click="false">
			<view class="check-type-popup">
				 <view class="title">检查路线规划方式</view>
				 <view class="check-type-box">
					 <text class="check-type-btn" @tap="intelligentPlanning">按智能规划检查 </text>
					 <text class="check-type-btn" @tap="oneselfPlanning">自行检查</text>
				</view>
			</view>
		</uni-popup> -->
		<uni-popup ref="shortTypePopup" type="bottom"  :mask-click="false">
			<view class="check-type-popup">
				 <view class="title">规划方式</view>
				 <view class="check-type-box">
					 <text class="check-type-btn" @tap="switchSortBy('2')">紧急程度</text>
					 <text class="check-type-btn" @tap="switchSortBy('3')">风险等级</text>
					 <text class="check-type-btn" @tap="switchSortBy('4')">距离最近</text>
				</view>
			</view>
		</uni-popup> 
		<CommonSearchCompontVue ref="CommonSearchCompontVueRef"  @seacharResult="seacharResult" :showTime="tabIndex == 1" :showCheckStatus="true" :showProcessResults="tabIndex == 1"
		 :showSearchCompont="showSearchCompont"  ></CommonSearchCompontVue>
		 <uni-popup ref="companyTypePop" type="bottom"  :mask-click="false">
		 	<view class="company-type-popup">
		 		 <view class="title">检查环节</view>
		 		 <view class="company-type-box" >
		 			<view class="company-type-view" v-for="(process,index) in regulatoryProcessDataNew"> 
						<text class="company-type-btn" @tap="searchCompanyType(process.value)"> {{process.text}} </text>
					</view>
		 		</view>
		 	</view>
		 </uni-popup> 
	<!-- 	<uni-popup ref="regulatoryProcessPopup" type="bottom">
			<view class="check-type-popup">
				<view class="title">检查环节</view>
				<view class="regulatoryProcessPopup">
				      最初单选版  
					  <uni-data-select v-model="companyProcess" :localdata="regulatoryProcessData" :clear="true"
						@change="switchProcess"></uni-data-select>  
						
					  新版多选版  
					<view class="regulatoryProcessButton">
						<button
							v-for="(btn, index) in regulatoryProcessDataNew"
							:key="index"
							:id="btn.value.toString()"
							:class="{ 'selected': btn.selected }"
							@click="toggleSelected(index)"
						>
						  {{ btn.text }}
						</button>
					</view>
					<button @click="confirmSelection" class="confirmSelection">确认</button>
				</view>
			</view>
		</uni-popup> -->
		<uni-popup ref="businessFormatPopup" type="bottom">
			<view class="check-type-popup">
				<view class="title">一级业态</view>
				<view class="businessFormatPopup">
					<!-- <uni-data-select v-model="companyProcess" :localdata="regulatoryProcessData" :clear="true"
						@change="switchProcess"></uni-data-select> -->
						<!-- 最初单选版 -->
						<!-- <uni-data-select v-model="firstType" :localdata="firstTypeList" :clear="true"
							@change="switchType"></uni-data-select> -->
						<!-- 新版多选版 -->	
						<w-select
							v-model='chooseValue' 
							:list='regulatoryProcessDataSecondary'
							multiple
							valueName='TEXT' 
							keyName="VALUE"
						>
						</w-select>
						<button @click="switchProcessConfirm" class="switchProcessConfirm">确认</button>
				</view>
			</view>
		</uni-popup>
	</view>
</template>

<script>
	import CommonSearchCompontVue from '../../components/CommonSearchCompont.vue'
	import commonNavBar from '@/components/CommonNavBar.vue';
	
	export default {
		components:{
			commonNavBar,
			CommonSearchCompontVue
		},
		data() {
			return { 
				stepList: [{
					step: '日常检查',
					active: true
				}, {
					step: '检查结果',
					active: false
				}],
				roteStatus: false,
				roteCheckedIndex:[],//导航选中的企业id
				sortIndex:0, 
				tabIndex:0,
				showSearchCompont:false,
				inspectList: [], 
				total: 0, 
				searchParams:{ 
					pageNum:1,
					pageSize:10,
					longitude:'',
					latitude:'',
					orderBy:'1'
				},
				// 最初单选版
				// regulatoryProcessData: null,//监管环节列表数据
				// companyProcess:'',//监管环节
				// firstType:'',//一级业态
				// firstTypeList: [],
				// 新版多选版
				regulatoryProcessDataNew: [],//监管环节列表数据
				regulatoryProcessDataSecondary: null,
				chooseValue: [],
			}
		},
		onLoad(options) {
			//从首页点过来传递的参数
			this.searchParams.checkStatus = options.index == null ? '1' : options.index
		},   
		async onReady() {
			// 最初单选版
			// this.$refs.shortTypePopup.open();
			// this.regulatoryProcessData = uni.getStorageSync('regulatoryProcessList');
			// 新版多选版
		
			
			const res = await  uni.$api.getProcessCodeList();
			if(res.data.code == 0){
				for (var i = 0; i < res.data.data.length; i++) {
					this.regulatoryProcessDataNew.push({
						value:res.data.data[i].id,
						text:res.data.data[i].name,
						code:res.data.data[i].code
					})
				}
			} 
			this.$refs.shortTypePopup.open();
			// this.regulatoryProcessDataNew = uni.getStorageSync('regulatoryProcessList').map((e, i) => {
			// 	return {
			// 		...e,
			// 		selected: true
			// 	};
			// });
			
			  let currentWebview = this.$mp.page.$getAppWebview() //获取当前页面的webview对象
			   currentWebview.setStyle({ popGesture: 'none' })
			//this.$refs.checkTypePopup.open();
		}, 
		methods: {
			formateNumber(value){ 
				if(value == undefined || value == 'undefined'){
					return '无坐标';
				}
				if(!isNaN(value)){ 
					return parseFloat(value).toFixed(2) + '米'
				} else {
					return value ;
				}
			},
			productionGetCheckClass(checkStatus) {
				switch (checkStatus){
					case '0':
						return '';
					case '1':
						return 'Active';
					case '2':
						return 'noNeed';
					case '3':
						return 'Expired';
					case '4':
							return 'NotYetDue';
					default:
						return '';
				} 
			},
			toggleSelected(index) {
				 this.regulatoryProcessDataNew[index].selected = !this.regulatoryProcessDataNew[index].selected;
				
			},
			async searchCompanyType(processId){
				this.$refs.CommonSearchCompontVueRef.switchProcessById(processId); 
				this.searchParams.processId = processId;
				this.$refs.companyTypePop.close();
				
				if( this.searchParams.orderBy == '4'){
					const that = this;
					//获取当前位置 
					let localInfo = await uni.$mapUtil.getCurrentPosition(); 
					 that.searchParams.latitude = localInfo.latitude
					 that.searchParams.longitude = localInfo.longitude
					 that.$refs.paging.reload(); 
				} else {
									
					this.$refs.paging.reload();
									//this.$refs.checkTypePopup.close();
				}
			},
			async confirmSelection() {
				const selectedButtons = this.regulatoryProcessDataNew.filter(btn => btn.selected);

				const selectedId = selectedButtons.map(btn => btn.value);
				const selectedCode = selectedButtons.map(btn => btn.code); 
			/* 	const res = await  uni.$api.getCompanyTypeList({
					processId : selectedId.toString(),
					code: selectedCode.toString()
				});   */
					
				//this.regulatoryProcessDataSecondary = res.data.data 
				this.$refs.regulatoryProcessPopup.close();
				this.searchParams.processBathQueryId =  selectedId.toString()//一级业态
				this.searchParams.processBathQueryCode =  selectedCode.toString()//一级业态
				 
				if( this.searchParams.orderBy == '4'){
					const that = this;
					//获取当前位置
					uni.showLoading({
						title: '获取当前位置',
						mask: true
					})
					uni.getLocation({
						type: 'gcj02',
						altitude: false,
						geocode: false,
						accuracy: 'best',
						isHighAccuracy: true,
						success(localInfo) { 
							that.searchParams.latitude = localInfo.latitude
							that.searchParams.longitude = localInfo.longitude
							that.$refs.paging.reload();
							//that.$refs.checkTypePopup.close();
						},
						fail(){
							uni.showModal({
								title:'提示',
								content:'获取位置失败，请检查是否开启定位权限',
								showCancel:false
							})
						},
						complete(){
							uni.hideLoading();
						}
					})
				} else {
									
					this.$refs.paging.reload();
									//this.$refs.checkTypePopup.close();
				}
				
				
				//this.$refs.businessFormatPopup.open();
			},
			async switchProcessConfirm() {
				console.log('eJoin', this.chooseValue)
				var pureData = this.chooseValue.map(function(obj) {
				  return Object.assign({}, obj);
				});

				console.log(JSON.stringify(pureData))
				 this.searchParams.processBathQueryEntity = JSON.stringify(pureData)//一级业态
				 this.$refs.businessFormatPopup.close(); 
						  
				 if( this.searchParams.orderBy == '4'){
					const that = this;
					//获取当前位置
					uni.showLoading({
						title: '获取当前位置',
						mask: true
					})
					uni.getLocation({
						type: 'gcj02',
						altitude: false,
						geocode: false,
						accuracy: 'best',
						isHighAccuracy: true,
						success(localInfo) { 
							that.searchParams.latitude = localInfo.latitude
							that.searchParams.longitude = localInfo.longitude
							that.$refs.paging.reload();
							//that.$refs.checkTypePopup.close();
						},
						fail(){
							uni.showModal({
								title:'提示',
								content:'获取位置失败，请检查是否开启定位权限',
								showCancel:false
							})
						},
						complete(){
							uni.hideLoading();
						}
					})
				 } else {
					
					this.$refs.paging.reload();
					//this.$refs.checkTypePopup.close();
				 }
			},
			open() { 
				this.showSearchCompont = true
			},
			checkToBeExamined(checkList){ 
				//如果存在待检查状态返回false，不存在返回true
				//获取应该检查的次数
				for (var i = 0; i < checkList.length; i++) {
					if(checkList[i].CHECK_STATUS == '3'){
						return false;
					}
				}
				return true;
			},
			getCheckClass(checkStatus){
				//获取检查状态对应的class   special
				switch (checkStatus){
					case '1':
						return 'Active';
					case '2':
						return 'Expired';
					case '3':
						return '';
					case '4':
						return 'NotYetDue';
					default:
						return '';
				} 
			},
			checkedActive(state,index){
				const  that = this;
				//导航选择按钮 
				if(state == undefined || !state) {
					this.$set(this.inspectList[index],"roteCheck",true);
					this.roteCheckedIndex.push( this.inspectList[index]);
				} else {
					this.$set(this.inspectList[index],"roteCheck",false);
					// 使用splice方法删除数组中的某个数字 
					let indexe =  -1;
					for (var i = 0; i < this.roteCheckedIndex.length; i++) {
						if(this.roteCheckedIndex[i].ID = this.inspectList[index].ID){
							indexe = i;
						}
					} 
					if (indexe > -1) {
					  this.roteCheckedIndex.splice(indexe, 1); // 删除索引为index的元素
					}
				} 
			},
			switchSortBy(type){
				this.$refs.shortTypePopup.close();
				this.$refs.companyTypePop.open();
				this.searchParams.orderBy = type;
				
			},
			// intelligentPlanning(){
			// 	this.searchParams.orderBy = '2'
			// 	this.$refs.paging.reload();
			// 	this.$refs.checkTypePopup.close();
			// },
			// oneselfPlanning(){
			// 	this.searchParams.orderBy = '1'
			// 	this.$refs.paging.reload();
			// 	this.$refs.checkTypePopup.close();
			// },
			checkRoute(){
				this.roteStatus = !this.roteStatus
			},
			seacharResult(e){
				console.log('e', e)
				//检索条件点击确定或者删除的时候在执行
				this.showSearchCompont =  false;
				if(e.search){
					this.searchParams = e;
					this.$refs.paging.reload();
				} 
			},
			goBack() {
				uni.navigateBack();
			},
			routePlan(){
				//路线规划
				const that = this;
				if(that.roteCheckedIndex.length == 0){
					uni.showToast({
						icon:'error',
						title:'请先选择企业'
					})
					return;
				} 
			 	uni.navigateTo({
					url: '/pages/inspect/route',
				  success: function(res) {
					// 通过eventChannel向被打开页面传送数据
					res.eventChannel.emit('searchData',{
						companyArr:that.roteCheckedIndex,
						checktype: 1
					})
				  }
				}) 
				 
				
			},
			async listData(pageNo, pageSize,reload) { 
				this.searchParams.pageNum = pageNo;
				this.searchParams.pageSize= pageSize;
				this.searchParams.type = this.tabIndex;
				try { 
					const res = await uni.$api.inspectList(this.searchParams); 
					this.$refs.paging.completeByKey(res.data.data.records,this.tabIndex);
					this.total = res.data.data.total
				}  catch (error) { 
					 this.$refs.paging.complete(false);
				}
			},
			// 最初单选版
			// async switchProcess(e){ 
			// 	for (var i = 0; i < this.regulatoryProcessData.length; i++) {
			// 		if(this.regulatoryProcessData[i].value == e){
			// 			this.companyIndex = i;
			// 			break;
			// 		}
			// 	} 
			// 	this.firstType = '';
			// 	this.twoType = '';
			// 	this.firstTypeList = []; 
			// 	//切换环节  
			// 	const res = await  uni.$api.getCompanyTypeList({
			// 		processId : this.regulatoryProcessData[this.companyIndex].value,
			// 		code:this.regulatoryProcessData[this.companyIndex].code
			// 	});  
			// 	 if(res.data.code == 0){
			// 	 	for (var i = 0; i < res.data.data.length; i++) {
			// 	 		this.firstTypeList.push({
			// 	 			value:res.data.data[i].VALUE,
			// 	 			text:res.data.data[i].TEXT 
			// 	 		})
			// 	 	}
			// 	 }  
			// 	 this.$refs.regulatoryProcessPopup.close();
			// 	 this.$refs.businessFormatPopup.open();
			// },
			// async switchType(e){
			// 	const  that = this;
			// 	this.twoTypeList= []; 
			// 	//切换企业类型 ,获取二级企业类型
			// 	const res = await  uni.$api.getCompanyTypeList({
			// 		processId : this.regulatoryProcessData[this.companyIndex].value,
			// 		code : this.regulatoryProcessData[this.companyIndex].code,
			// 		parentId : e
			// 	});  
			// 	 if(res.data.code == 0){
			// 	 	for (var i = 0; i < res.data.data.length; i++) {
			// 	 		this.twoTypeList.push({
			// 	 			value:res.data.data[i].VALUE,
			// 	 			text:res.data.data[i].TEXT 
			// 	 		})
			// 	 	}
			// 	 } 
			// 	 this.searchParams.processId = this.companyProcess,//监管环节
			// 	 this.searchParams.businessFormatId = this.firstType,//一级业态
			// 	 this.$refs.businessFormatPopup.close(); 
		  
			// 	 if( this.searchParams.orderBy == '4'){
			// 	 	const that = this;
			// 	 	//获取当前位置
			// 	 	uni.showLoading({
			// 	 		title: '获取当前位置'
			// 	 	})
			// 	 	uni.getLocation({
			// 	 		type: 'gcj02',
			// 	 		altitude: false,
			// 	 		geocode: false,
			// 	 		accuracy: 'best',
			// 	 		isHighAccuracy: true,
			// 	 		success(localInfo) { 
			// 	 			that.searchParams.latitude = localInfo.latitude
			// 	 			that.searchParams.longitude = localInfo.longitude
			// 	 			that.$refs.paging.reload();
			// 	 			//that.$refs.checkTypePopup.close();
			// 	 		},
			// 	 		fail(){
			// 	 			uni.showModal({
			// 	 				title:'提示',
			// 	 				content:'获取位置失败，请检查是否开启定位权限',
			// 	 				showCancel:false
			// 	 			})
			// 	 		},
			// 	 		complete(){
			// 	 			uni.hideLoading();
			// 	 		}
			// 	 	})
			// 	 } else {
					
			// 	 	this.$refs.paging.reload();
			// 	 	//this.$refs.checkTypePopup.close();
			// 	 }
			// },
			checkState(aleeadyCheckNums,index){
				if(aleeadyCheckNums == undefined ){
					return false;
				}
				//判断是否已经检查完成
				const numberList = aleeadyCheckNums.split(",");
				for (var i = 0; i < numberList.length; i++) {
					if(parseInt(numberList[i]) === (index+1) ){
						return true;
					}
				}
				return false; 
			}, 
			stepActive(index) {
				this.tabIndex = index;
				this.$refs.paging.reload(); 
			},
			resultListActive(id,isAuthority,checkList,supProcess){
				if(!this.roteStatus) {
					const that = this; 
					//当前应该检查的次数
					let  checkIndex = null;
					let  checkId = null;
					let  checkStatus = null;
					//获取应该检查的次数
					for (var i = 0; i < checkList.length; i++) {
						if(checkList[i].CHECK_STATUS == '3'){
							checkIndex = checkList[i].CHECK_INDEX;
							checkId = checkList[i].CHECK_ID;
							checkStatus = checkList[i].CHECK_STATUS;
						}
					}
					// if(checkIndex == null){
					// 	//获取过期未检查
					// 	for (var i = 0; i < checkList.length; i++) {
					// 		if(checkList[i].CHECK_STATUS == '2'){
					// 			checkIndex = checkList[i].CHECK_INDEX;
					// 		}
					// 	}
					// }
					if(checkIndex == null){
						that.addInspect(id,isAuthority,supProcess)
						/* uni.showModal({
							title:'提示',
							content:'当前周期日常检查已完成，您要进行非计划检查吗?',
							success: (res) => {
								if(res.confirm){
									that.addInspect(id,isAuthority,supProcess)
								}
							}
						}) */
					} else {
						that.addInspect(id,isAuthority,supProcess,checkStatus, checkIndex,checkId) 
						/* uni.showActionSheet({
							title: '请选择您要执行的检查',
							itemList:['进行第'+checkIndex+'次日常检查' , '进行非计划检查'  ], 
							success: (res) => {
								if(res.tapIndex == 0){
									// 日常检查
									that.addInspect(id,isAuthority,supProcess,checkStatus, checkIndex,checkId) 
								} else  if(res.tapIndex == 1){
									//非计划 
									that.addInspect(id,isAuthority,supProcess,'3')
								}  
							}
						}) */
					} 
				}
			},
			addInspect(id,isAuthority,supProcess,status,index,checkId) {
				if(status == '1' ){
					//已经检查完成的点击进入到查看页面
					uni.navigateTo({
						url: '/pages/inspect/resultActive?id=' + checkId
					})
					return;
				}
				
		 		if(isAuthority != '1'){ 
					//没有权限操作
					uni.showToast({
						icon:'error',
						title: '无操作权限',
						duration: 4000
					})
					return;
				} 
				console.log("进入检查")
				//未检查的情况可以进行检查，
				//TODO已过期但是有审核通过的情况也是可以检查，后面要加上
				if(status == '3'){
					uni.navigateTo({
						url: '/pages/inspect/addInspectTabs?companyId=' + id +"&checkNum="+ index + "&checkId="+checkId+"&supProcess="+supProcess
						 // + '&addInspectOId=' + oid
					})
				}
			},
			// 新增生产
			productionAddInspect(id,isAuthority,status,inspectId,serialNum) {
				//不知道生产要不要这个权限
				// if(isAuthority != '1'){
				// 	//没有权限操作
				// 	uni.showToast({
				// 		icon:'error',
				// 		title: '无操作权限',
				// 		duration: 4000
				// 	})
				// 	 return;
				// } 
				if(status == '1' ){
					//已经检查完成的点击进入到查看页面
					uni.navigateTo({
						url: '/pages/productionInspect/productionResultActive?id=' + inspectId + "&companyId=" + id
					})
					return;
				}
				
				if(status == '0' || status == '-1'){
					uni.navigateTo({
						url: '/pages/productionInspect/productionAddInspectTabs?inspectId=' + inspectId + "&companyId=" + id + "&status=" + status + "&serialNum=" + serialNum
					})
					return;
				}
				
				if(!status){
					uni.navigateTo({
						url: '/pages/productionInspect/productionAddInspectTabs?companyId=' + id + "&serialNum=" + serialNum
					})
					return;
				}
			},
			close() {
				this.$refs.popup.close()
			}, 
			cancellation() {
				this.close()
			} ,
			showShortType(){
				this.$refs.shortTypePopup.open();
			}
		},
		watch: {
			
		},
	}
</script>

<style lang="scss">
	.inspectContent {
		background: #F9F9F9;
		height: calc(100vh - 195rpx);

		.upper {
			position: fixed;
			z-index: 1;
			top: 0;
			left: 0;
			width: 100%;

			.title {
				background: url('../../static/img/inspectBg.png');
				background-size: cover;
				width: 100%;
				height: 115rpx;
				line-height: 115rpx;
				position: relative;
				display: flex;
				justify-content: center;

				.arrow {
					position: absolute;
					left: 33rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 100rpx;
					height: 100rpx;
					 
					&::before {
						display: block;
						content: "";
						position: absolute;
						top: 50%;
						left: 0%;
						width: 20rpx;
						height: 20rpx;
						border-left: 1px solid #fff;
						border-top: 1px solid #fff;
						transform: translate(0%, -50%) rotate(-45deg);
					}
				}

				text {
					font-size: 30rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					letter-spacing: 1px;
				}

				.screen {
					position: absolute;
					right: 80rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 35rpx;
					height: 33rpx;
				}
				.screen1 {
					position: absolute;
					right: 30rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 35rpx;
					height: 33rpx;
				}
				
				.routePlanning {
					position: absolute;
					right: 130rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 28rpx;
					height: 33rpx;
				}
				
				.routePlanning2 {
					position: absolute;
					right: 170rpx;
					top: 50%;
					transform: translate(0%, -50%);
					width: 28rpx;
					height: 33rpx;
				}
			}

			.step {
				display: flex;
				justify-content: space-around;
				height: 80rpx;
				line-height: 80rpx;
				background: #F9F9F9;

				view {
					position: relative;
					font-size: 25rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #999999;

					&.active {
						color: #0552A9;

						&::before {
							display: block;
							content: "";
							position: absolute;
							left: 50%;
							bottom: 0%;
							transform: translate(-50%, 0%);
							width: 100rpx;
							height: 5rpx;
							background: #0552A9;
						}
					}
				}
			}
		}

		.centre { 
			height: calc(100vh - 280rpx);
			overflow-x: hidden;
			padding-top: 115rpx;
			
			.z-paging-content-fixed {
				padding: 195rpx 0 0 0;
			}

			.li {
				background: linear-gradient(180deg, #FFFFFF 0%, #FFFFFF 100%);
				box-shadow: 0rpx 8rpx 15rpx 0rpx rgba(0, 0, 0, 0.05);
				border-radius: 15rpx;
				padding: 30rpx 30rpx 15rpx 28rpx;
				position: relative;
				margin: 13rpx 20rpx 0;

				.float {
					position: absolute;
					top: 0;
					right: 0;
					// width: 97rpx;
					padding: 0 10rpx;
					height: 46rpx;
					line-height: 46rpx;
					background: linear-gradient(180deg, #5DA1FF 0%, #0054C9 100%);
					border-radius: 0rpx 11rpx 0rpx 11rpx;
					font-size: 18rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #FFFFFF;
					text-align: center;
				}

				.h1 {
					font-size: 24rpx;
					font-family: PingFangSC-Medium, PingFang SC;
					font-weight: 500;
					color: #333333;
					line-height: 1;
					margin: 0 0 14rpx 0;
				}

				.h2 {
					font-size: 19rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #666666;
					line-height: 1;
					margin: 12rpx auto;
				}

				.order {
					margin: 24rpx auto 0; 
					white-space: nowrap;
					overflow-x: auto; 
					
					.dd {
						width: 120rpx;
						height: 55rpx;
						border-radius: 9rpx;
						border: 1rpx solid #979797;
						font-size: 20rpx;
						font-family: PingFangSC-Medium, PingFang SC;
						font-weight: 700;
						color: #A1A1A1; 
						position: relative;
						text-indent: -10rpx;
						display: inline-block;
						text-align: center; 
						border: 1px solid #F9A240;
						background: #F9A240;
						color: #fff;
						
						.dd1 { 
							display: flex;
							flex-direction: column;
							align-items: center;
							justify-content: center; 
							height: 55rpx;
						}

						 
	
						.triangle {
							width: 0;
							height: 0;
							border-top: 8rpx solid transparent;
							border-bottom: 8rpx solid transparent;
							border-left: 10rpx solid #A1A1A1;
							border-left: 10rpx solid #fff;
							position: absolute;
							top: 50%;
							right: 4rpx;
							transform: translate(-50%, -50%);
						}

						&+.dd {
							margin: 0 0 0 12rpx;
						}

						&.Active {
							border: 1px solid #00BE8C;
							background: #00BE8C;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
						
						&.Expired  {
							border: 1px solid #f95e5a;
							background: #f95e5a;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
						
						&.NotYetDue  {
							border: 1px solid #999999;
							background: #999999;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
						
						&.special { 
							border: 1px solid #026DC6;
							background: #026DC6;
							color: #fff;
							
							.triangle {
								border-left: 10rpx solid #fff;
							}
						}
					}
				}
			}
		}

		.fixed {
			display: none;
			position: fixed;
			left: 50%;
			bottom: 26rpx;
			transform: translate(-50%, 0);
			width: 100%;
			text-align: center;
			font-size: 18rpx;
			font-family: PingFangSC-Regular, PingFang SC;
			font-weight: 400;
			color: #A7A7A7;
		}

		.popupContent {
			background: #FFFFFF;
			border-radius: 20rpx 20rpx 0 0;

			.uni-datetime-picker {
				width: 100%;
			}

			.title {
				width: 100%;
				height: 80rpx;
				line-height: 80rpx;
				background: url('../../static/img/popupTitle.png') no-repeat center center;
				background-size: cover;
				font-size: 25rpx;
				font-family: PingFangSC-Medium, PingFang SC;
				font-weight: 500;
				color: #FFFFFF;
				text-indent: 45rpx;
			}

			.ul {

				.li {
					padding: 0 45rpx;
					margin: 0 auto;
					display: flex;
					justify-content: space-between;
					align-items: center;
					min-height: 68rpx;
					line-height: 68rpx;
					border-bottom: 1px solid #d6d6d6;
						
					.left {
						font-size: 21rpx;
						font-family: PingFangSC-Regular, PingFang SC;
						font-weight: 400;
						color: #333333;
					}
						
					.right {
						
						input {
							font-size: 21rpx;
							font-family: PingFangSC-Regular, PingFang SC;
							font-weight: 400;
							color: #999999;
							width: 460rpx;
							text-indent: 20rpx;
						}
						
						.placeholder-class {
							color: #999999;
						}
						
						.uni-stat__select {
							width: 460rpx;

							/deep/.uni-select {
								border: none;
							}
						}
						
						.uni-date {
							width: 460rpx;
							
							/deep/.uni-date-editor--x {
								border: none;
							}
						}
					}
					
					&:nth-child(odd) {
						background: #F9F9F9;
					}
					
					&:last-child {
						border-bottom: none;
					}
				}
				
				.li:last-child {
					/deep/.uni-select__selector {
						top: initial;
					}
					
					/deep/.uni-popper__arrow {
						display: none;
					}
				}
			}
			
			.button {
				margin: 58rpx auto 0;
				padding: 0 95rpx 24rpx 95rpx;
				display: flex;
				
				button {
					width: 269rpx;
					height: 55rpx;
					line-height: 55rpx;
					background: #0552A9;
					border-radius: 10rpx;
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
				
					&.determine {
						color: #fff;
					}
					
					&.cancellation {
						background: none;
						border: 1rpx solid #979797;
						color: #979797;
					}
				}
			}
		}
	}
	.navigator-check{
		position: absolute;
		width: 100rpx;
		height: 100rpx;
		z-index: 9;
		right: 0px;
		bottom: 0px;
		border-radius: 0rpx 0rpx 15rpx 0rpx;
	}
	.check-type-popup{
		
		.title{
			width: 750rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: url('/static/img/popupTitle.png') no-repeat center center;
			background-size: cover;
			font-size: 25rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			// text-indent: 45rpx;
			text-align: center;
		}
		.check-type-box{
			display: flex;
			flex-direction: row;
			justify-content: space-around;
			align-items: center;
			background-color: #fff; 
			padding: 40rpx 0px 30rpx 0rpx;
			
			.check-type-btn{ 
				height: 55rpx;
				line-height: 55rpx;
				padding: 0px 20rpx;
				background-color: #0552A9;
				border-radius: 10rpx;
				font-size: 20rpx;
				font-family: PingFangSC-Regular, PingFang SC;
				font-weight: 400;
				color: #fff;
				text-align: center;
			}
		}
		
	}

	
	.search-item{
		display: flex;
		flex-direction: row; 
		justify-content: center;
		align-items: center;
		
		.search-active{
			color: #0054C9;
		}
		
		.search-text{
			color: #999999;
		}
		
		.search-icon{
			width: 25rpx;
			height:30rpx;
			margin-right: 10rpx; 
		}
	}
	
	.regulatoryProcessPopup,.businessFormatPopup {
		background: #fff;
		padding: 20rpx;
		
		/deep/.uni-select__selector {
			top: initial;
			bottom: calc(100% + 18rpx);
		}
		
		/deep/.uni-popper__arrow {
			top: initial;
			bottom: -8px;
			left: initial;
			right: 10%;
			transform: rotate(180deg);
		}
	}
	
	.selected {
		background-color: #A9D18E;
		color: #fff;
	}
	
	.regulatoryProcessButton {
		display: flex;
		flex-wrap: wrap;
		justify-content: space-between;
		
		button {
			flex-basis: 49%;
			margin: 1% 0;
			font-size: 20rpx;
			border: 1rpx solid #000;
		}
	}
	
	.confirmSelection {
		font-size: 20rpx;
		background: #5B9BD5;
		color: #fff;
		border: 1rpx solid #000;
		margin: 2% auto 0;
		z-index: 99999999;
	}
	
	/deep/.select-wrap {
		width: 100% !important;
		margin: 0 auto 3%;
	}
	
	.switchProcessConfirm {
		font-size: 20rpx;
		background: #5B9BD5;
		color: #fff;
		border: 1rpx solid #000;
		margin: 2% auto 0;
		z-index: 99999999;
	}
	
	.company-type-popup{
		
		.title{
			width: 750rpx;
			height: 80rpx;
			line-height: 80rpx;
			background: url('/static/img/popupTitle.png') no-repeat center center;
			background-size: cover;
			font-size: 25rpx;
			font-family: PingFangSC-Medium, PingFang SC;
			font-weight: 500;
			color: #FFFFFF;
			// text-indent: 45rpx;
			text-align: center;
		}
		.company-type-box{
			display: flex;
			flex-direction: column;
			justify-content: space-around;
			background-color: #fff; 
			padding: 15rpx 0px 30rpx 0rpx;
			
			.company-type-view{
				text-align: center;
				padding: 5px 15px;
				border-bottom: 1px solid #e3e3e3;
				
				.company-type-btn{
					height: 55rpx;
					line-height: 55rpx;
					
					font-size: 20rpx;
					font-family: PingFangSC-Regular, PingFang SC;
					font-weight: 400;
					color: #000000;
				}
			}
			
		}
		
	}
	
	.fixed {
		display: block;
		position: fixed;
		left: 50%;
		bottom: 26rpx;
		transform: translate(-50%, 0);
		width: 100%;
		text-align: center;
		font-size: 18rpx;
		font-family: PingFangSC-Regular, PingFang SC;
		font-weight: 400;
		color: #A7A7A7;
	}
	
</style>
